package com.stock_t.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.stock_t.entity.StockPool;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface StockPoolMapper extends BaseMapper<StockPool> {
    List<StockPool> selectStockPoolList(StockPool stockPool);

    /**
     * 获取股票的股数构成（买入价格和对应股数）
     */
    @Select("SELECT buy_price as price, buy_shares as shares FROM stock_pool " +
            "WHERE stock_code = #{stockCode} AND buy_shares > 0 " +
            "ORDER BY buy_price ASC")
    List<Map<String, Object>> selectShareComposition(@Param("stockCode") String stockCode);

}